import pydirectinput

class DirectSoundDevice:
    def __init__(self, device_name: str):
        self.device = pydirectinput.DirectSoundCreate(device_name)

    def play(self, buffer: bytes):
        """播放音频"""
        self.device.Write(buffer)